﻿@namespace AntDesign
@inherits AntDomComponentBase

@if (Simple)
{
    @simpleTemplate(this)
}
else
{
    <div class="@WrapperClassMapper.Class" @ref="Ref">
        <div>
            @simpleTemplate(this)
        </div>
    </div>
}

@code{
    RenderFragment defaultTemplate =
        @<span class="ant-spin-dot ant-spin-dot-spin">
            <i class="ant-spin-dot-item"></i>
            <i class="ant-spin-dot-item"></i>
            <i class="ant-spin-dot-item"></i>
            <i class="ant-spin-dot-item"></i>
        </span>;

    RenderFragment<Spin> simpleTemplate = spin=>
        @<Template>
            @if (spin._isLoading)
            {
                <div class="@spin.ClassMapper.Class" id="@spin.Id" style="@spin.Style" @ref="spin.Ref">
                    @if (spin.Indicator != null)
                    {
                        @spin.Indicator
                    }
                    else
                    {
                        @spin.defaultTemplate
                    }
                    @if (spin.Tip != null)
                    {
                        <div class="ant-spin-text">@spin.Tip</div>
                    }
                </div>
            }

            @if (!spin.Simple)
            {
                <div class="ant-spin-container @spin.ContainerClass">
                    @spin.ChildContent
                </div>
            }
        </Template>;
}